package com.example.yls.broadcastreceiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

/**
 * Created by yls on 2018/11/6.
 */

public class MyBroadcastReceiver extends BroadcastReceiver {


    @Override
    public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if(action.equals("weather_info")) {
        String weather = intent.getStringExtra("weather");
        int warn = intent.getIntExtra("warn", 0);
        Log.e("MyBroadcastReceiver",
                "OnReceiver 天气"
                        + weather + " 温度 " + warn +"度");

    }
    else if(action.equals("traffic_info")){
        String traffic = intent.getStringExtra("traffic");
        int time = intent.getIntExtra("time", 0);
        Log.e("MyBroadcastReceiver",
                "OnReceiver 交通"
                        + traffic + " 时间 " +  time +"时");
        }



    }
}
